-
The Windows API (WinAPI) is the low-level programming interface of the Windows operating system. Its main purpose is to allow programs to interact directly with OS resources.
-
Create and manage windows
-
Manipulate files and directories
-
Manage processes and threads
-
Access hardware and devices
-
Manage memory
-
Network communication
-
Graphical interface (GDI)
-
-
The Windows API in C sounds terribly complex, confusing, unintuitive, and very outdated.
-
ChatGPT: "It’s common among programmers that the Windows API in C (WinAPI) is confusing, verbose, and old-fashioned."
-
Casey: He agrees that the API is bad.
-
"it's crazy, I'm never going to defend the design of the Windows API".
-
He doesn’t like using Windows.
-
"It’s crazy how new APIs and Windows updates make everything increasingly ridiculous."
-
-
Extensive Use of Pointers and Opaque Types
-
Many types are just
void*aliases, likeHANDLE,LPARAM,WPARAM, making it difficult to understand what is actually being handled.
-
-
Excessive Macros and Definitions
-
The API uses macros excessively (
#definefor constants and window messages), making the code hard to navigate and understand.
-
-
Archaic and Inconsistent Naming
-
Functions start with prefixes like
Create,Get,Set, but don’t always follow an intuitive pattern. -
Example:
CreateWindowExdoes not directly create a window, just registers it.
-
-
Use of C-Style Strings and Verbose Structures
-
Many functions require manually filling huge structs (e.g.,
WNDCLASSEXto create a window).
-
-
Explicit Resource Management
-
The programmer must manually manage memory allocations, handlers, and system objects, risking leaks if forgotten.
-
-
Confusing and Historical Documentation
-
Many functions have legacy versions from Windows 3.1/95 (
CreateWindow,CreateWindowEx, etc.), adding complexity when deciding which to use.
-
-
Opaque Error Messages
-
To understand an error, often you must call
GetLastError()and then useFormatMessage()to make it readable.
-
-
-
Is WinAPI still used today?
-
Yes, but less directly. Today, most developers use frameworks that encapsulate WinAPI, like:
-
C++ with Qt, wxWidgets, or WinRT
-
C# with .NET and WPF
-
Rust with
winapi-rs -
Electron (JavaScript) for cross-platform apps
-
-
If you need low-level development on Windows (like drivers, emulators, or embedded software), WinAPI is still the official route.
-
-
Do you need WinAPI for games?
-
No, if you are using frameworks like SDL, RayLib, SFML, GLFW, or engines like Unity/Unreal.
-
Frameworks like SDL, RayLib, SFML, GLFW, and even engines like Unity and Unreal remove almost all need to interact directly with WinAPI. They act as an abstraction layer, letting the developer focus on the game itself.
-
-
Yes, if you want to build a graphics engine from scratch or integrate specific Windows features.
-
WIndows C API